<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><?php echo $title?></title>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/ssi_common.js"></script>
<script type="text/javascript" src="../../js/chosen.jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.placeholder.js"></script>
<script type="text/javascript" src="../../js/icheck.min.js"></script>

<link href="../../style/global.css" type="text/css" rel="stylesheet" />
<link href="../../style/media.css" type="text/css" rel="stylesheet" />
<link href="../../style/icheck/green.css" type="text/css" rel="stylesheet" />
<link href="../../style/chosen/chosen.min.css" type="text/css" 	rel="stylesheet" />
<link href="../../style/db.css" type="text/css" rel="stylesheet" />

<script type="text/javascript">
$(document).ready(function(){

	$(".v-option").click(function(){
		
		if($(this).text()=="更多"){
			$(this).find("span").html("<b></b>收起");
			$(this).prev().find(".f-list").css("height","auto");
		}else{
			$(this).find("span").html("<b></b>更多");
			$(this).prev().find(".f-list").css("height","22px");
		}
	});
	$(".area_select").chosen({disable_search:true});
	if (window.navigator.appName === "Microsoft Internet Explorer") {
	        return document.documentMode >= 8;
	}
	$('#start_price').placeholder();
	$('#end_price').placeholder();
	$('.g_radio').iCheck({
	      checkboxClass: 'icheckbox_minimal-green',
	      radioClass: 'iradio_minimal-green',
	      increaseArea: '20%' // optional
	    });
	$(".search").find("li").click(function(){
		$(this).siblings().removeClass('on');
		$(this).addClass("on");
		$("#media_type").val($(this).attr("data"));
		if ($(this).attr("data")=="highway") {
			$("#city").html("<option value=''>请选择</option>");
			$("#area").html("<option value=''>请选择</option>");
			$("#province").trigger("chosen:close");
			$("#city").trigger("chosen:updated");
			$("#area").trigger('chosen:updated');
			$("#area_zone").hide();

			$("#city").attr("name","highway");
			
			$("#city_zone").find(".chosen-container").css("width","220px");
			province_change();
		}else if($(this).attr("data")=="airport") {
			$("#city").html("<option value=''>请选择</option>");
			$("#area").html("<option value=''>请选择</option>");
			$("#city").trigger("chosen:updated");
			$("#area").trigger('chosen:updated');
			$("#area_zone").hide();

			$("#city").attr("name","airport");

			
			$("#city_zone").find(".chosen-container").css("width","220px");
			province_change();
		}else{
			$("#city").html("<option value=''>请选择</option>");
			$("#area").html("<option value=''>请选择</option>");
			$("#city").trigger("chosen:updated");
			$("#area").trigger('chosen:updated');
			$("#area_zone").show();

			$("#city").attr("name","city");
			
			$("#city_zone").find(".chosen-container").css("width","130px");
			province_change();
		}
		
	});
	$("#start_price").click(function(){
		$('.g_radio').iCheck('uncheck');
	});
	$("#end_price").click(function(){
		$('.g_radio').iCheck('uncheck');
	});
	$('.g_radio').on('ifChecked', function(event){
		$("#start_price").val("");
		$("#end_price").val("");
	});

});
function province_change(){
	var province = $("#province").val();
	if (province=="") {
		return ;	
	}
	if($("#media_type").val()=="common"||$("#media_type").val()=="led"){
		$.getJSON("<?php echo base_url()."index.php/region/get_regions"?>", { region_id: province }, function(json){
			$("#city").html("<option value=''>请选择</option>");
			$("#area").html("<option value=''>请选择</option>");
			if (json.length == 0) {
				$("#city").trigger('chosen:updated');
				$("#area").trigger('chosen:updated');
				return;
			}
			for(var i = 0, len = json.length; i<len; ++i){
				var region = json[i];
				$("#city").append("<option value=" + region.region_id + ">" + region.region_name + "</option>");
			}
			$("#city").trigger('chosen:updated');
			$("#area").trigger('chosen:updated');
		});
	}else if($("#media_type").val()=="highway"){
		$.getJSON("<?php echo base_url()."index.php/region/get_highways"?>", { region_id: province }, function(json){
			$("#city").html("<option value=''>请选择</option>");
			if (json.length == 0) {
				$("#city").trigger('chosen:updated');
				return;
			}
			
			for(var i = 0, len = json.length; i<len; ++i){
				var highway = json[i];
				$("#city").append("<option value=" + highway.highway_id + ">" + highway.highway_name + "</option>");
			}
			$("#city").trigger('chosen:updated');
		});
		
	}else if ($("#media_type").val()=="airport") {
		$.getJSON("<?php echo base_url()."index.php/region/get_airports"?>", { region_id: province }, function(json){
			$("#city").html("<option value=''>请选择</option>");
			if (json.length == 0) {
				$("#city").trigger('chosen:updated');
				return;
			}
			for(var i = 0, len = json.length; i<len; ++i){
				var airport = json[i];
				$("#city").append("<option value=" + airport.airport_id + ">" + airport.airport_name + "</option>");
			}
			$("#city").trigger('chosen:updated');
		});
		
	}
}
function city_change(){
	var city = $("#city").val();
	$.getJSON("<?php echo base_url()."index.php/region/get_regions"?>", { region_id: city }, function(json){
		if (json.length == 0) {
			return;
		}
		$("#area").html("<option value=''>请选择</option>");
		for(var i = 0, len = json.length; i<len; ++i){
			var region = json[i];
			$("#area").append("<option value=" + region.region_id + ">" + region.region_name + "</option>");
		}
		$("#area").trigger('chosen:updated');
	});
}
</script>
</head>
<body>